#include <iostream>
#include <algorithm>
using namespace std;
const int N = 2e5 + 10;
int q[N];
void solve()
{
	int n, m, h;
	int ans = 1;
	cin >> n >> m >> h;
	int le = 0, dele = 0, ti = 0, deti = 0;
	int a, b, c;
	for (int i = 0; i < m; i++)
		cin >> q[i];
	sort(q, q + m);
	int h2 = h;
	int sum = 0;
	for (int i = 0; i < m; i++)
	{
		h2 -= q[i];
		//cout<<h2<<'.'<<i<<'=';
		if (h2 < 0)
			break;
		le = i + 1;
		sum += q[i];
		ti += sum;
	}
	cout << ti << '.';
	for (int i = 1; i < n; i++)
	{
		sum = 0;
		int h2 = h;
		dele = 0, deti = 0;
		for (int j = 0; j < m; j++)
			cin >> q[j];
		sort(q, q + m);
		for (int j = 0; j < m; j++)
		{
			h2 -= q[j];
			if (h2 < 0)
				break;
			dele = j + 1;
			sum += q[j];
			deti = deti + sum;
		}
		cout << deti << '.';
		if (dele > le) ans++;
		else if (dele == le && deti < ti) ans++;
	}

	cout << ans << endl;
}
int main()
{
	int t;
	cin >> t;
	while (t--)
		solve();
	return 0;
}